#ifndef RESPONSIVEFACTORY_H
#define RESPONSIVEFACTORY_H

#include <QPointer>
#include "responsivefilelistengine.h"
#include "responsivefileitem.h"
#include "adaptivefilelayout.h"
#include "responsiveconfig.h"

/**
 * 🎨 ResponsiveFactory - Sony Ive 响应式组件工厂
 *
 * 统一创建和管理响应式组件，确保一致的配置和性能优化
 */

class ResponsiveFactory
{
public:
    // === 单例模式 ===
    static ResponsiveFactory& instance();

    // === 核心组件创建 ===
    ResponsiveFileListEngine* createResponsiveEngine(QObject* parent = nullptr);
    AdaptiveFileLayout* createAdaptiveLayout(QObject* parent = nullptr);
    ResponsiveFileItem* createResponsiveFileItem(const UnifiedFileInfo& fileInfo,
                                                 ResponsiveFileListEngine* engine = nullptr,
                                                 QWidget* parent = nullptr);

    // === 配置管理 ===
    void applySonyDesignDefaults(ResponsiveFileListEngine* engine);
    void applyPerformanceOptimizations(ResponsiveFileListEngine* engine);
    void enableResponsiveMode(CustomFileListWidget* widget, bool enabled = true);

    // === 全局配置 ===
    void setGlobalResponsiveMode(bool enabled);
    bool isGlobalResponsiveModeEnabled() const;
    void setAnimationEnabled(bool enabled);
    bool isAnimationEnabled() const;

private:
    ResponsiveFactory() = default;
    ~ResponsiveFactory() = default;
    ResponsiveFactory(const ResponsiveFactory&) = delete;
    ResponsiveFactory& operator=(const ResponsiveFactory&) = delete;

    // === 内部状态 ===
    bool m_globalResponsiveMode = ResponsiveConfig::DEFAULT_RESPONSIVE_MODE;
    bool m_animationEnabled = ResponsiveConfig::DEFAULT_SONY_ANIMATIONS;
    bool m_performanceOptimization = ResponsiveConfig::DEFAULT_PERFORMANCE_OPTIMIZATION;
};

// === 便捷宏定义 ===
#define ResponsiveFactoryInstance() ResponsiveFactory::instance()

#endif // RESPONSIVEFACTORY_H